<style> 
.input_text{width:57%}
.input_btn{width:-10px;margin-top:-9px}
.percent{display:none !important}
.percent_show{display:block}
.btn_edit{width:88%}
</style>
<script language="javascript">
$().ready(function(){
	function empty_value(){
		$(".percent_text").val("");
		$(".btn_edit").css("display","block");
		$(".percent_text").addClass("percent");
		$(".percent_btn").addClass("percent");
	}
	$(".btn_edit").click(function(){
		var $index = $(".btn_edit").index(this);
		empty_value();
		$(this).css("display","none");
		$(".percent_text").eq($index).removeClass("percent");
		$(".percent_btn").eq($index).removeClass("percent");
		return false;
	});
	$(".input_btn").click(function(){
		if(confirm("Bạn có muốn cập nhật giá")){
			return true;	
		}
		return false;
	});
});
</script>
<?php if($this->session->flashdata("success")){?><p style="background:rgb(106, 234, 92);padding:5px;text-align:center;font-weight:bold"><?php echo $this->session->flashdata("success")?></p><?php }?>
<form action="<?php echo site_url("admin/products/update_price_product_categoy")?>" method="post">
<table class="table table-striped">
      <thead>
          <tr>
              <th colspan="2" ><?php echo lang('name')?></th>
          </tr>
      </thead>

  <?php
  function list_categories($parent_id, $cats, $sub='', $product_categories,$refix='') {
      foreach ($cats[$parent_id] as $cat): ?>
      <tr>
          <td><?php echo  $sub.$cat->name; ?></td>
          <td style="width:20%">
          	  <a class="btn btn_edit" href=""><i class="icon-pencil"></i>Sửa</a>
              <input class="percent percent_text input_text" type="text" placeholder="Phần trăm" value="" name="price_category[<?php echo $cat->id?>]"> 
              <input class=" percent percent_btn input_btn" type="submit" value="Cập nhật" >
          </td>
          
      </tr>
      <?php
      if (isset($cats[$cat->id]) && sizeof($cats[$cat->id]) > 0)
      {
          $sub2 = str_replace('&rarr;&nbsp;', '&nbsp;', $sub);
              $sub2 .=  '&nbsp;&nbsp;&nbsp;&rarr;&nbsp;';
          list_categories($cat->id, $cats, $sub2, $product_categories,$cat->id);
      }
      endforeach;
  }

  list_categories(0, $categories, '', $product_categories,'');
  ?>
</table>
</form>